package cn.tedu.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class JDBC3 {
    public static void main(String[] args) throws Exception {
        //1.
        Class.forName("com.mysql.cj.jdbc.Driver");
        String url="jdbc:mysql://localhost:3306/cgb2015";
        String user="root";
        String psw="root";
        Connection conn = DriverManager.getConnection(url, user, psw);
        Statement st = conn.createStatement();
        String sql="insert into dept values(null,'java','北京')";
        int rows = st.executeUpdate(sql);
        System.out.println("数据插入成功");
        st.close();
        conn.close();
    }
}
